﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lession3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.button1.Size = new System.Drawing.Size(75, 23);
            AddBtnEvent(button1);
        }

        /// <summary>  
        /// 添加按钮上鼠标 移入、移出、按下、弹起 事件  
        /// </summary>  
        /// <param name="btn">操作的按钮</param>  
        private void AddBtnEvent(Button btn)
        {
            btn.MouseEnter += delegate (object sender, EventArgs e)
            {
                ((Button)sender).BackgroundImage = Properties.Resources.share;
                btn.Size = new System.Drawing.Size(78, 26);
            };
            btn.MouseLeave += delegate (object sender, EventArgs e)
            {
                ((Button)sender).BackgroundImage = Properties.Resources.share;
                btn.Size = new System.Drawing.Size(75, 23);
            };
            btn.MouseDown += delegate (object sender, MouseEventArgs e)
            {
                ((Button)sender).BackgroundImage = Properties.Resources.share;
                btn.Size = new System.Drawing.Size(78, 26);
            };
            btn.MouseUp += delegate (object sender, MouseEventArgs e)
            {
                ((Button)sender).BackgroundImage = Properties.Resources.share;
                btn.Size = new System.Drawing.Size(75, 23);
            };
        }
    }
}
